#!/usr/bin/python

import sys
import SocketServer

class MirrorHandler(SocketServer.StreamRequestHandler):
	def handle(self):
		while True:
			c = self.rfile.readline().strip()
			if c:
				self.wfile.write(c) + '\n'

if __name__ == '__main__':
	if len(sys.argv) >= 2:
		host = sys.argv[1]
	else:
		host = 'localhost'

	if len(sys.argv) >= 3:
		port = int(sys.argv[2])
	else:
		port = 20866
	
	SocketServer.TCPServer((host, port), MirrorHandler).serve_forever()